package com.xuzm.sping.spark.demo.test;

import org.apache.spark.sql.Dataset;
import org.apache.spark.sql.Row;
import org.apache.spark.sql.SparkSession;

public class SparkSqlDemo {
    public static void main(String[] args) {
        SparkSession spark = SparkSession
                .builder().master("local")
                .appName("Java Spark SQL basic example")
                .config("spark.some.config.option", "some-value")
                .getOrCreate();
        Dataset<Row> df = spark.read().json("file:///D:\\produce\\workspace\\base-demo\\hadoop-demo\\spring-spark-demo\\src\\main\\resources\\people.json");
        df.show();
        df.createOrReplaceTempView("people");
        Dataset<Row> sqlDF = spark.sql("select * from  people where age>12");
        sqlDF.show();
        spark.stop();
    }
}
